// const { whenDev, whenProd, when } = require('@craco/craco')
const sassResourcesLoader = require('craco-sass-resources-loader');
const path = require('path');
const resolve = dir => path.resolve(__dirname, dir);

module.exports = {
    babel: {
        plugins: [
            [ // 按需加载antd
                "import",
                {
                    "libraryName": "antd",
                    "libraryDirectory": "es",
                    "style": "css" // `style: true` 会加载 less 文件
                }
            ]
        ],
    },
    webpack: {
        alias: { // 修改别名
            '@': resolve('./src')
        }
    },
    plugins: [
        {
            plugin: sassResourcesLoader,
            options: {
                resources: resolve('./src/assets/css/global.scss'),
            },
        },
    ],
    style: {
        postcss: {
            mode: 'extends',
            loaderOptions: {
                postcssOptions: {
                    ident: 'postcss',
                    plugins: [
                        require('autoprefixer')(overrideBrowserslist=['last 20 versions', 'android >= 4.0', 'iOS >= 7'])
                    ],
                },
            },
        },
    },

}